﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MethodWorx.CMS.Administration;

namespace MethodWorx.CMS.UI.Models
{
    public class AdministrationSummaryModel
    {
        private IApplicationSettingsRepository settings;

        public AdministrationSummaryModel(IApplicationSettingsRepository settings)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");

            this.settings = settings;

            var savedSettings = this.settings.FindSettings();
            if (savedSettings != null)
            {
                var applicationType = ApplicationTypeFactory.Instance.GetApplicationTypes().FirstOrDefault(at => at.ApplicationTypeId == savedSettings.ApplicationTypeId);
                if (applicationType != null)
                {
                    this.ApplicationType = applicationType.Name;
                    this.BaseUri = savedSettings.BaseUri;
                    this.AssetUri = savedSettings.AssetUri;
                }
                
            }
        }

        public string ApplicationType { get; private set; }
        public string BaseUri { get; private set; }
        public string AssetUri { get; private set; }
    }
}